var kafka=require('kafka-node'),
    Consumer=kafka.Consumer,
    client=new kafka.Client(),
    consumer=new Consumer(
        client,
        [
            {topic:'CAR_NUMBER',partition:0}
        ],
        {
            autoCommit:false,
            fetchMaxWaitMs: 1000,
            fetchMaxBytes: 1024 * 1024,
            fromOffset: true
        }
    );
var mysql=require('mysql');
var connection=mysql.createConnection({
    "host":"47.104.248.43",
    "user":"root",
    "password":"share.ykplay.com",
    "database":"seckill"
});
connection.connect();
consumer.on('message',function(message){
    console.log("得到的生产者的数据为：",message)
    connection.query('insert into seckill set ?',{date:new Date()},function(error,results,fields){
        if(error){
            console.error(error);
        }
        console.log("插入数据库成功");
    });
})